<?php

function smarty_function_get_category_by_id($params, &$smarty) {
    //Get value from page
    $category_id = $params['id'];
    if($category_id){
      //Query data

      //Check exist user & topic
      $pntables = pnDBGetTables();
      $table  = $pntables['innoforum_category'];
      $column = $pntables['innoforum_category_column'];

      $sql = "SELECT
                $table.$column[name]  
              FROM
                $table 
              WHERE
                $table.$column[id] = ".$category_id;

      $column = array("name");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      $category = $objectArray['0']['name'];
    }
    if ($category) {
        $smarty->assign('categoryName', $category); 
    } else {
        return "";
    }
}